Change in openvpn[master]: buffer: Change buf_prepend and buf_advance to accept ssize_t for length
A message that is not in the archive (sent off-list or not yet received): gerrit.1765538409000.I123002255b37160d48ef6481f68a89d03073236b@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1437?usp=email
to review the following change.
Change subject: buffer: Change buf_prepend and buf_advance to accept ssize_t for length
......................................................................
buffer: Change buf_prepend and buf_advance to accept ssize_t for length
We already have tests to make sure the value is sane. Changing the argument to ssize_t allows to use it in more places without needing to do a cast before the checks.
---
M src/openvpn/buffer.c
M src/openvpn/buffer.h
M src/openvpn/ps.c
3 files changed, 10 insertions(+), 10 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/37/1437/1
src/openvpn/buffer.c +2 -2
@@ -789,7 +789,7 @@ {if (buf_string_match_head_str (src, match)) { -buf_advance (src, (int )strlen (match)); +buf_advance (src,strlen (match));return true; }else
@@ -1312,7 +1312,7 @@ }void -buffer_list_advance (struct buffer_list *ol,int n) +buffer_list_advance (struct buffer_list *ol,ssize_t n) {if (ol->head) {
src/openvpn/buffer.h +7 -7
@@ -601,26 +601,26 @@*/ static inline uint8_t * -buf_prepend (struct buffer *buf,int size) +buf_prepend (struct buffer *buf,ssize_t size) {if (!buf_valid (buf) || size <0 || size > buf->offset) {return NULL ; } - buf->offset -= size; - buf->len += size; + buf->offset -= (int )size; + buf->len += (int )size;return BPTR (buf); }static inline bool -buf_advance (struct buffer *buf,int size) +buf_advance (struct buffer *buf,ssize_t size) {if (!buf_valid (buf) || size <0 || buf->len < size) {return false; } - buf->offset += size; - buf->len -= size; + buf->offset += (int )size; + buf->len -= (int )size;return true; }
@@ -1175,7 +1175,7 @@*/ struct buffer *buffer_list_peek (struct buffer_list *ol); -void buffer_list_advance (struct buffer_list *ol,int n); +void buffer_list_advance (struct buffer_list *ol,ssize_t n);void buffer_list_pop (struct buffer_list *ol);
src/openvpn/ps.c +1 -1
@@ -596,7 +596,7 @@ {dmsg (D_PS_PROXY_DEBUG ,"PORT SHARE PROXY: partial write[%d], tried=%d got=%zd" , (int )sd, pc->buf.len, status); -buf_advance (&pc->buf, (int )status); +buf_advance (&pc->buf, status);return IOSTAT_EAGAIN_ON_WRITE ; } else
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1437?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I123002255b37160d48ef6481f68a89d03073236b
Gerrit-Change-Number: 1437
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: flichtenheld, plaisthos.
cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1437?usp=email )
Change subject: buffer: Change buf_prepend and buf_advance to accept ssize_t for length
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1437?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I123002255b37160d48ef6481f68a89d03073236b
Gerrit-Change-Number: 1437
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 15 Dec 2025 16:05:25 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
PATCH 1/1 buffer: Change buf_prepend and buf_advance to accept ssize_t for length
In reply to a message not in the archiveFrom: Frank Lichtenheld <[email protected]...>
We already have tests to make sure the value is sane. Changing the argument to ssize_t allows to use it in more places without needing to do a cast before the checks.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1437
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1437
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/buffer.c +2 -2
@@ -789,7 +789,7 @@ {if (buf_string_match_head_str (src, match)) { -buf_advance (src, (int )strlen (match)); +buf_advance (src,strlen (match));return true; }else
@@ -1312,7 +1312,7 @@ }void -buffer_list_advance (struct buffer_list *ol,int n) +buffer_list_advance (struct buffer_list *ol,ssize_t n) {if (ol->head) {
src/openvpn/buffer.h +7 -7
@@ -601,26 +601,26 @@*/ static inline uint8_t * -buf_prepend (struct buffer *buf,int size) +buf_prepend (struct buffer *buf,ssize_t size) {if (!buf_valid (buf) || size <0 || size > buf->offset) {return NULL ; } - buf->offset -= size; - buf->len += size; + buf->offset -= (int )size; + buf->len += (int )size;return BPTR (buf); }static inline bool -buf_advance (struct buffer *buf,int size) +buf_advance (struct buffer *buf,ssize_t size) {if (!buf_valid (buf) || size <0 || buf->len < size) {return false; } - buf->offset += size; - buf->len -= size; + buf->offset += (int )size; + buf->len -= (int )size;return true; }
@@ -1175,7 +1175,7 @@*/ struct buffer *buffer_list_peek (struct buffer_list *ol); -void buffer_list_advance (struct buffer_list *ol,int n); +void buffer_list_advance (struct buffer_list *ol,ssize_t n);void buffer_list_pop (struct buffer_list *ol);
src/openvpn/ps.c +1 -1
@@ -596,7 +596,7 @@ {dmsg (D_PS_PROXY_DEBUG ,"PORT SHARE PROXY: partial write[%d], tried=%d got=%zd" , (int )sd, pc->buf.len, status); -buf_advance (&pc->buf, (int )status); +buf_advance (&pc->buf, status);return IOSTAT_EAGAIN_ON_WRITE ; } else
[Openvpn-devel] [PATCH applied] Re: buffer: Change buf_prepend and buf_advance to accept ssize_t for length
Looks reasonable, compiles fine :-) - and I really should have merged this one before #1438 (upsetting -Werror compiles for everyone).
Your patch has been applied to the master branch.
commit cb4d5426d0751ce4720fbc7531de51731725a5fb
Author: Frank Lichtenheld Date: Mon Dec 15 17:05:35 2025 +0100
buffer: Change buf_prepend and buf_advance to accept ssize_t for length
Signed-off-by: Frank Lichtenheld <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1437
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35099.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Attention is currently required from: flichtenheld.
plaisthos has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1437?usp=email )
Change subject: buffer: Change buf_prepend and buf_advance to accept ssize_t for length
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1437?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I123002255b37160d48ef6481f68a89d03073236b
Gerrit-Change-Number: 1437
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 15 Dec 2025 16:08:32 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
cron2 has uploaded a new patch set (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1437?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2, Code-Review+2 by plaisthos
Change subject: buffer: Change buf_prepend and buf_advance to accept ssize_t for length
......................................................................
buffer: Change buf_prepend and buf_advance to accept ssize_t for length
We already have tests to make sure the value is sane. Changing the argument to ssize_t allows to use it in more places without needing to do a cast before the checks.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1437
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35099.html
---
M src/openvpn/buffer.c
M src/openvpn/buffer.h
M src/openvpn/ps.c
3 files changed, 10 insertions(+), 10 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/37/1437/2
src/openvpn/buffer.c +2 -2
@@ -789,7 +789,7 @@ {if (buf_string_match_head_str (src, match)) { -buf_advance (src, (int )strlen (match)); +buf_advance (src,strlen (match));return true; }else
@@ -1312,7 +1312,7 @@ }void -buffer_list_advance (struct buffer_list *ol,int n) +buffer_list_advance (struct buffer_list *ol,ssize_t n) {if (ol->head) {
src/openvpn/buffer.h +7 -7
@@ -601,26 +601,26 @@*/ static inline uint8_t * -buf_prepend (struct buffer *buf,int size) +buf_prepend (struct buffer *buf,ssize_t size) {if (!buf_valid (buf) || size <0 || size > buf->offset) {return NULL ; } - buf->offset -= size; - buf->len += size; + buf->offset -= (int )size; + buf->len += (int )size;return BPTR (buf); }static inline bool -buf_advance (struct buffer *buf,int size) +buf_advance (struct buffer *buf,ssize_t size) {if (!buf_valid (buf) || size <0 || buf->len < size) {return false; } - buf->offset += size; - buf->len -= size; + buf->offset += (int )size; + buf->len -= (int )size;return true; }
@@ -1187,7 +1187,7 @@*/ struct buffer *buffer_list_peek (struct buffer_list *ol); -void buffer_list_advance (struct buffer_list *ol,int n); +void buffer_list_advance (struct buffer_list *ol,ssize_t n);void buffer_list_pop (struct buffer_list *ol);
src/openvpn/ps.c +1 -1
@@ -596,7 +596,7 @@ {dmsg (D_PS_PROXY_DEBUG ,"PORT SHARE PROXY: partial write[%d], tried=%d got=%zd" , (int )sd, pc->buf.len, status); -buf_advance (&pc->buf, (int )status); +buf_advance (&pc->buf, status);return IOSTAT_EAGAIN_ON_WRITE ; } else
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1437?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I123002255b37160d48ef6481f68a89d03073236b
Gerrit-Change-Number: 1437
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1437?usp=email )
Change subject: buffer: Change buf_prepend and buf_advance to accept ssize_t for length
......................................................................
buffer: Change buf_prepend and buf_advance to accept ssize_t for length
We already have tests to make sure the value is sane. Changing the argument to ssize_t allows to use it in more places without needing to do a cast before the checks.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1437
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35099.html
---
M src/openvpn/buffer.c
M src/openvpn/buffer.h
M src/openvpn/ps.c
3 files changed, 10 insertions(+), 10 deletions(-)
src/openvpn/buffer.c +2 -2
@@ -789,7 +789,7 @@ {if (buf_string_match_head_str (src, match)) { -buf_advance (src, (int )strlen (match)); +buf_advance (src,strlen (match));return true; }else
@@ -1312,7 +1312,7 @@ }void -buffer_list_advance (struct buffer_list *ol,int n) +buffer_list_advance (struct buffer_list *ol,ssize_t n) {if (ol->head) {
src/openvpn/buffer.h +7 -7
@@ -601,26 +601,26 @@*/ static inline uint8_t * -buf_prepend (struct buffer *buf,int size) +buf_prepend (struct buffer *buf,ssize_t size) {if (!buf_valid (buf) || size <0 || size > buf->offset) {return NULL ; } - buf->offset -= size; - buf->len += size; + buf->offset -= (int )size; + buf->len += (int )size;return BPTR (buf); }static inline bool -buf_advance (struct buffer *buf,int size) +buf_advance (struct buffer *buf,ssize_t size) {if (!buf_valid (buf) || size <0 || buf->len < size) {return false; } - buf->offset += size; - buf->len -= size; + buf->offset += (int )size; + buf->len -= (int )size;return true; }
@@ -1187,7 +1187,7 @@*/ struct buffer *buffer_list_peek (struct buffer_list *ol); -void buffer_list_advance (struct buffer_list *ol,int n); +void buffer_list_advance (struct buffer_list *ol,ssize_t n);void buffer_list_pop (struct buffer_list *ol);
src/openvpn/ps.c +1 -1
@@ -596,7 +596,7 @@ {dmsg (D_PS_PROXY_DEBUG ,"PORT SHARE PROXY: partial write[%d], tried=%d got=%zd" , (int )sd, pc->buf.len, status); -buf_advance (&pc->buf, (int )status); +buf_advance (&pc->buf, status);return IOSTAT_EAGAIN_ON_WRITE ; } else
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1437?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I123002255b37160d48ef6481f68a89d03073236b
Gerrit-Change-Number: 1437
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>